﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;

public partial class adm_vlg_Admin_master : System.Web.UI.MasterPage
{
    CommonPage cm3 = new CommonPage();
    VLGDataContext _db8 = new VLGDataContext();
    protected void Page_Load(object sender, EventArgs e)
    {
        //FUNCTION.rootPath = GetApplicationPath();
        if (Session["AID"] == null)
            Response.Redirect("loginForm.aspx?returnURL="+Request.Url);

        //string action = Request.QueryString["action"];
        //if (action != null && action == "logout")
        //{
        //    Session["AID"] = null;
        //    Response.Redirect("login.aspx");
        var acc= (from a in _db8.VLGAccounts
                 where a.idAcc==Convert.ToInt32(Session["AID"])
                 select a).Single();

        if (!acc.idGroup.ToLower().Equals("admin"))
        {
            Response.Redirect(ResolveClientUrl("~/accessDenied.aspx"));
        }
        //var query_taikhoan = _db8.VLGAccounts.Where(c => c.idAcc == Convert.ToInt32(Session["AID"])).FirstOrDefault();

        ltr_AName.Text = acc.UsernameE;

        //ltr_preview.Text = "<a href=\"" + CODE.funtion.GetValueWebConfig("domain") +"\" class=\"preview\"  target=_blank>Xem trước</a>";
        //ltr_webmail.Text = "<a href=\""+CODE.funtion.GetValueWebConfig("webmail")+"\" target=_blank>Web Mail</a>";
        //ltr_truy_cap.Text = "Lượt truy cập: " + Application["visitors_online"].ToString() + "/" + CODE.funtion.GetValueWebConfig("tong_truy_cap");

    }

    public string GetApplicationPath()
    {
        string applicationPath = "";

        if (this.Page.Request.Url != null)
            applicationPath = this.Page.Request.Url.AbsoluteUri.Substring(
             0, this.Request.Url.AbsoluteUri.ToLower().IndexOf(
              this.Request.ApplicationPath.ToLower(),
               this.Request.Url.AbsoluteUri.ToLower().IndexOf(
              this.Page.Request.Url.Authority.ToLower()) +
              this.Page.Request.Url.Authority.Length) +
             this.Request.ApplicationPath.Length);
        return applicationPath;
    }

}
